package com.hst.capacity.infra.persistence.jpa.setting.price;

import com.hst.capacity.domain.model.entity.setting.price.ExpressStpPriceEntity;
import com.hst.capacity.domain.model.response.setting.price.ExpressStpSearchVO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface ExStpPriceRepository extends CrudRepository<ExpressStpPriceEntity, String> {

    /**
     * 通过地区查找站点价格
     * @param regionCode
     * @param carpoolType（0：拼车 1：包车）
     * @return
     */
    List<ExpressStpPriceEntity> findByRegionCodeAndCarpoolType(String regionCode, int carpoolType);

    @Query("select new com.hst.capacity.domain.model.response.setting.price.ExpressStpSearchVO(p,s) from ExpressStpPriceEntity p left join StationEntity s on p.idStation=s.idStation where p.idFranchisee=:idFranchisee")
    Page<ExpressStpSearchVO> findByIdFranchisee(String idFranchisee, PageRequest pageRequest);

    ExpressStpPriceEntity findByIdFranchiseeAndIdStationAndIdVehicleTypeAndCarpoolType(String idf,String reg,Integer vt,Integer ct);

}
